(async function(){        
    //获取得到奖励的一览表
    setLoading(1);
    var salary = await getMySalary();
    setLoading(0);
    var list = getNode("history");
    var line = list.children[0];
    if(salary.length>0){
        clearAll(list);
        for(var i=salary.length-1;i>=0;i--){
            var si = salary[i];
            if(si.approved && si.start.toNumber() != si.lastPay.toNumber()){
                var f=false;
                var newLine = line.cloneNode(true);
                var reason = getSubNode(newLine,"reason");
                var date = getSubNode(newLine,"time");
                var amount = getSubNode(newLine,"amount");
                reason.innerText = salary[i].reason;
                if (si.period.toNumber()==ONCE){
                    amount.innerText = format(si.amount);
                    date.innerText = dateFormat(si.start);
                    f=true;
                }else if (si.period.toNumber()==DAY){
                    var day = Math.ceil((si.lastPay.toNumber()- si.start.toNumber())/DAY);
                    if (day>0){
                        //超过1天领取
                        amount.innerText = parseFloat(format(si.amount))*day;
                        date.innerText = dateFormat(si.start) + " 后共"+day+"天";
                        f=true;
                    }
                }else if (si.period.toNumber()==MONTH){
                    var month= Math.ceil((si.lastPay.toNumber()- si.start.toNumber())/MONTH);
                    if (month>0){
                        //超过1个月领取
                        amount.innerText = parseFloat(format(si.amount))*month;
                        date.innerText = dateFormat(si.start) + " 后共"+month+"月";
                        f=true;
                    }
                }else if (si.period.toNumber()==YEAR){
                    var year = Math.ceil((si.lastPay.toNumber()- si.start.toNumber())/YEAR);
                    if (year>0){
                        //超过1年领取
                        amount.innerText = parseFloat(format(si.amount))*year;
                        date.innerText = dateFormat(si.start) + " 后共"+year+"年";
                        f=true;
                    }
                }
                if (f) list.appendChild(newLine);
            }
        }
    }
})();